package main

import "fmt"

func testArray1() {
	var numList1 [5]int = [5]int{1, 2, 3, 4, 5}
	var numList2 = [5]int{1, 2, 3, 4, 5}
	numList3 := [5]int{1, 2, 3, 4, 5}

	for index, value := range numList1 {
		fmt.Println("[func|testArray1|numList1]index=", index, "value=", value)
	}
	fmt.Println()

	for index, value := range numList2 {
		fmt.Println("[func|testArray1|numList2]index=", index, "value=", value)
	}
	fmt.Println()

	for index, value := range numList3 {
		fmt.Println("[func|testArray1|numList3]index=", index, "value=", value)
	}
	fmt.Println()
}

func testArray2() {
	var strList1 = [...]string{"a", "b", "c"}
	strList2 := [...]string{"d", "e", "cf"}

	for index, value := range strList1 {
		fmt.Println("[func|testArray2|strList1]index=", index, "value=", value)
	}
	fmt.Println()

	for index, value := range strList2 {
		fmt.Println("[func|testArray2|strList2]index=", index, "value=", value)
	}
	fmt.Println()
}

func testArray3() {
	var numList [5]int = [5]int{1: 10, 3: 30}
	for index, value := range numList {
		fmt.Println("[func|testArray3|numList]index=", index, "value=", value)
	}
	fmt.Println()
}

func testArray4() {
	var numList [5]int = [5]int{1, 2, 3, 4, 5}
	num1 := numList[2]
	fmt.Println("[func|testArray4]num=", num1)
	num1 = 30
	fmt.Println("[func|testArray4]num=", num1)

	/**
	以下写法会报如下错误
	invalid argument: index 10 out of bounds [0:5]
	num2 := numList[10]
	*/
}

// func main() {
// 	testArray1()
// 	testArray2()
// 	testArray3()
// 	testArray4()
// }
